# !/usr/bin/env python
# encoding: utf-8


"""
  @author: gaogao
  @file: save_data_2_csv_util.py
  @time: 2022/4/9 14:03
  @desc:
"""

import csv

data_content = [[[0.0, 0.035, 0.07, 0.10500000000000001, 0.14, 0.17500000000000002, 0.21000000000000002,
                  0.24500000000000002, 0.28, 0.31500000000000006, 0.35000000000000003, 0.385, 0.42000000000000004,
                  0.45500000000000007, 0.49000000000000005, 0.525, 0.56, 0.5950000000000001, 0.6300000000000001, 0.665,
                  0.7000000000000001, 0.7350000000000001, 0.77, 0.805, 0.8400000000000001, 0.8750000000000001,
                  0.9100000000000001, 0.9450000000000001, 0.9800000000000001, 1.0150000000000001, 1.05,
                  1.0850000000000002, 1.12, 1.155, 1.1900000000000002, 1.225, 1.2600000000000002, 1.2950000000000002,
                  1.33, 1.3650000000000002, 1.4000000000000001, 1.435, 1.4700000000000002, 1.5050000000000001, 1.54,
                  1.5750000000000002, 1.61, 1.6450000000000002, 1.6800000000000002, 1.715, 1.7500000000000002,
                  1.7850000000000001, 1.8200000000000003, 1.8550000000000002, 1.8900000000000001, 1.9250000000000003,
                  1.9600000000000002, 1.995, 2.0300000000000002, 2.0650000000000004, 2.1, 2.1350000000000002,
                  2.1700000000000004, 2.205, 2.24, 2.2750000000000004, 2.31, 2.345, 2.3800000000000003, 2.415, 2.45,
                  2.4850000000000003, 2.5200000000000005, 2.555, 2.5900000000000003, 2.6250000000000004, 2.66,
                  2.6950000000000003, 2.7300000000000004, 2.765, 2.8000000000000003, 2.8350000000000004, 2.87,
                  2.9050000000000002, 2.9400000000000004, 2.975, 3.0100000000000002, 3.0450000000000004, 3.08, 3.115,
                  3.1500000000000004, 3.1850000000000005, 3.22, 3.2550000000000003, 3.2900000000000005, 3.325,
                  3.3600000000000003, 3.3950000000000005, 3.43, 3.4650000000000003, 3.5000000000000004],
                 [-20.4503441, -20.4146996, -20.2845421, -20.0465355, -19.7734947, -19.4818764, -19.0781631,
                  -18.6652908, -18.1744003, -17.6357574, -17.1397095, -16.5352325, -16.0702934, -15.4918709,
                  -14.9077263, -14.2975998, -13.7340126, -13.1533508, -12.6008186, -12.02425, -11.503212, -10.9396973,
                  -10.4417496, -9.96339417, -9.4397049, -8.95291901, -8.50742722, -8.05931854, -7.61312866, -7.18651581,
                  -6.75593948, -6.40245438, -6.01610184, -5.64193726, -5.28615189, -4.98662949, -4.66059494,
                  -4.33567429, -4.06687927, -3.82341003, -3.62158966, -3.36926651, -3.15396118, -3.01684952,
                  -2.81529999, -2.6760025, -2.61326218, -2.51976013, -2.42363739, -2.39970779, -2.39328384, -2.42032623,
                  -2.48907089, -2.56725311, -2.68706131, -2.81825256, -3.03787231, -3.28985977, -3.57471466,
                  -3.92383194, -4.39897156, -4.9036026, -5.55462265, -6.17002869, -7.04148483, -7.86591339, -9.38781738,
                  -10.1432915, -12.5681381, -15.2668152, -18.0199776, -26.7985268, -36.4610901, -20.2762032,
                  -15.6746101, -12.1639099, -10.5475349, -9.18291092, -7.42059326, -7.22591782, -5.36420822,
                  -4.64856339, -3.75288773, -3.61128616, -2.89957809, -2.69897079, -2.50798035, -2.47938538,
                  -2.39499664, -2.5434761, -2.74773407, -3.18849564, -3.94584656, -4.60903931, -5.45979309, -7.44712448,
                  -9.96031952, -14.213131, -18.7443047, -26.0912323, -32.886879]]]


def saveData2CSV(file_path, header, data_content):
    with open(file_path, 'w', newline='', encoding="utf_8_sig") as csvfile:
        writer = csv.writer(csvfile)
        # 写入表格的标题
        writer.writerow(header)
        # 循环写入表格的内容
        for i in range(len(data_content[0][0])):
            row_data = []
            for j in range(len(data_content[0])):
                row_data.append(data_content[0][j][i])
            writer.writerow(row_data)


# saveData2CSV("DR4-S2-1.8mm.csv", ["Voltage", "Power"], data_content)
